﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace H1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Random random = new Random();
            this.textBox1.Text = random.Next(0,100).ToString();
            this.textBox2.Text = random.Next(0, 100).ToString();
            this.textBox3.Text = random.Next(0, 100).ToString();
            this.textBox4.Text = random.Next(0, 100).ToString();
            this.textBox5.Text = random.Next(0, 100).ToString();
            this.textBox6.Text = random.Next(0, 100).ToString();

        }

        private void button2_Click(object sender, EventArgs e)
        {
            if(this.textBox1.Text != null)
            {
                int[] a = new int[6];
                a[0] = int.Parse(textBox1.Text);
                a[1] = int.Parse(textBox2.Text);
                a[2] = int.Parse(textBox3.Text);
                a[3] = int.Parse(textBox4.Text);
                a[4] = int.Parse(textBox5.Text);
                a[5] = int.Parse(textBox6.Text);
                int max, min;
                max = min = a[0];
                for(int i = 0; i < a.Length; i++)
                {
                    if(a[i] > max)
                    {
                        max = a[i];
                    }

                }
                this.textBox7.Text = max.ToString();
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (this.textBox1.Text != null)
            {
                int[] a = new int[6];
                a[0] = int.Parse(textBox1.Text);
                a[1] = int.Parse(textBox2.Text);
                a[2] = int.Parse(textBox3.Text);
                a[3] = int.Parse(textBox4.Text);
                a[4] = int.Parse(textBox5.Text);
                a[5] = int.Parse(textBox6.Text);
                int max, min;
                max = min = a[0];
                for (int i = 0; i < a.Length; i++)
                {
                    if (a[i] < min)
                    {
                        max = a[i];
                    }

                }
                this.textBox8.Text = max.ToString();
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (this.textBox1.Text != null)
            {
                int[] a = new int[6];
                a[0] = int.Parse(textBox1.Text);
                a[1] = int.Parse(textBox2.Text);
                a[2] = int.Parse(textBox3.Text);
                a[3] = int.Parse(textBox4.Text);
                a[4] = int.Parse(textBox5.Text);
                a[5] = int.Parse(textBox6.Text);
                int sum = 0;
                foreach (int i in a)
                {
                    sum += i;
                }
                sum = sum/6;
                this.textBox9.Text = sum.ToString();
            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            if (this.textBox1.Text != null)
            {
                int[] a = new int[6];
                a[0] = int.Parse(textBox1.Text);
                a[1] = int.Parse(textBox2.Text);
                a[2] = int.Parse(textBox3.Text);
                a[3] = int.Parse(textBox4.Text);
                a[4] = int.Parse(textBox5.Text);
                a[5] = int.Parse(textBox6.Text);
                int sum = 0;
                foreach(int i in a)
                {
                    sum+=i;  
                }
                this.textBox10.Text = sum.ToString();
            }
        }
    }
}
